﻿using System.Runtime.CompilerServices;
using Windows.ApplicationModel.Resources;

namespace Smile.Localization
{
    /// <summary>
    ///     Base class to implement a LocalizedStrings object with a Windows Phone 8 style.
    ///     -   You have to implements a new* resw file like in this guideline :
    ///         http://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh965329(v=win.10).aspx.
    ///     -   Create properties with string key of the resw file as property name.  
    ///     -   Call "return GetLocalizedString();" in the "get" bracket.
    ///     
    ///     *The "rename a resx file" option doesn't works. Then you have to copy/paste the resx
    ///      file content into the resw file.
    /// </summary>
    public class LocalizedStringsBase
    {
        // @Properties
        public static ResourceLoader ResourceLoader
        {
            get
            {
                return _resourceLoader;
            }
        }

        
        // @Public
        public static ResourceLoader  _resourceLoader = new ResourceLoader();


        public static string GetLocalizedString([CallerMemberName] string propertyName = "")
        {
            if (ResourceLoader == null || string.IsNullOrWhiteSpace(propertyName))
            {
                return string.Empty;
            }
            return ResourceLoader.GetString(propertyName);
        }
    }
}
